<?php
namespace App\Http\Controllers\Admin;

use App\Service\Admin\QrService;
use Illuminate\Http\Request;

class QrController extends BaseController
{
    //二维码

    //列表
    public function index(Request $request)
    {
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = QrService::index($pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //扩充
    public function add(Request $request)
    {
        $res = QrService::add();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }

    //扫码记录
    public function log(Request $request)
    {
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $code = $request->post('code', '');
        $res = QrService::qrlog($pages, $code);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }
}